<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ page isELIgnored="false"%>
<html>
<head>
<title>Show Orders</title>
</head>

<body>
	<%@ page errorPage="common/error.jsp"%>
	<%@ include file="common/header.jsp"%>

	<a href="<c:url value="/order/new" />">Create new order</a>

	<h1>Order list</h1>

	<table border=1>
		<thead>
			<tr>
				<th>Order Id</th>
				<th>Order date</th>
				<th>Executed</th>
				<th>Books</th>
				<th>Total price</th>

			</tr>
		</thead>
		<tbody>
			<c:forEach items="${orders}" var="order">
				<tr>
					<td><a
						href="${pageContext.request.contextPath}/order/info?id=${order.id}">Order ${order.id}</a></td>
					<td><fmt:formatDate pattern="yyyy-MM-dd"
							value="${order.orderDate}" /></td>
					<td>${order.executed}</td>
					<td>
					<c:forEach items="${order.books}" var="book">
							<a href="${pageContext.request.contextPath}/book/info?id=${book.bookId}">${book.title}  
				  ${book.author} </a>
				        </br>
						</c:forEach>
						</td>

					<td><fmt:formatNumber value="${order.totalPrice}"
							type="number" /> USD</td>

				</tr>
			</c:forEach>
		</tbody>
	</table>

	<%@ include file="common/footer.jsp"%>
</body>
</html>